<?php
class Title extends ORDataObject {
	var $title_id		= '';
	var $vi_name			= '';
	var $en_name          = '';
	var $description	= '';

	var $_table 		= 'title';
	var $_key 			= 'title_id';
	var $_internalName	= 'Title';
	
	function Title() {
		parent::ORDataObject();
	}
	
	public function setup($id = 0){
		$this->set('id',$id);
		if($id > 0){
			$this->populate();
		}
	}
	
	public function populate(){
		parent::populate('title_id');
	}
	
	public function getId(){
		return $this->title_id;
	}
	
	public function setId($id){
		$this->title_id	=	$id;
	}
	
	public function getDescription(){
		return $this->description;
	}

	public function setData($name, $description){
	    $field = L10nHelper::changeField(L10nHelper::getLocale(), 'name');
		$data	=	array(
			$field 			=>	$name,
			'description'	=>	$description
		);
		$this->populateArray($data);
	}
	
	public function getTitleList(){
	    $field = L10nHelper::changeField(L10nHelper::getLocale(), 'name');
	    
		$ds		=	& new Datasource_sql();
		$sql	= array(
        	'cols'    => "title_id as id, $field AS name, description",
        	'from'    => "$this->_table",
        	'orderby' => 'id'
        );
        $ds->setup($this->_db,$sql);
        return $ds->toArray();
	}
}
?>
